#include "mainwindow.h"
#include "pukerclass.h"
#include "ui_mainwindow.h"
#include<QDebug>
#include<stdlib.h>
#include<time.h>
#include<QPainter>
#include<QMessageBox>
MainWindow::MainWindow(QWidget *parent) :
    QMainWindow(parent),
    ui(new Ui::MainWindow)
{
    ui->setupUi(this);
initui();
}

MainWindow::~MainWindow()
{
    for(int i=0;i<13;i++)
        delete [] vet[i];
    delete[] vet;
    delete ui;
}
void MainWindow::initui(){
    this->resize(1600,1200);
    this->setMaximumSize(1600,1200);
    this->setMinimumSize(1600,1200);
    this->setWindowTitle("德州puker玩法模拟");

    vet=new pukerclass* [13];
    for(int i=0;i<13;i++)
    {
        vet[i]=new pukerclass [4];
    }
}
void MainWindow::paintEvent(QPaintEvent *event){
   draw2();
   update();
   }
}
void MainWindow::draw2(){
   QPainter painter(this);
   painter.drawPixmap(0,0,1600,1200,QPixmap(":/drawer/微信图片_20220506221842.jpg"));
}
void MainWindow::cunchu(pukerclass **vet){
    for(int i=0;i<13;i++){
        for(int j=0;j<4;j++){
            vet[i][j].number=i+2;
            vet[i][j].type=j+1;
        }
    }
}
void MainWindow::randomshuchu(pukerclass *con){
int x[9],y[9],z[9][2];
int timea=0;
srand((int)time(0));
for(int i=0;i<20;i++){
    x[timea]=rand()%4+1;//类型的随机数
    y[timea]=rand()%13+2;//数码的随机数
    z[timea][0]=x[timea];
    z[timea][1]=y[timea];
    int same=0;
    for(int j=0;j<timea;j++){
        if(z[j][0]==x[timea]&&z[j][1]==y[timea])
            same++;
    }
    if(same==0)
        timea++;
    if(timea==9)
        break;
}
for(int i=0;i<9;i++){
    con[i].type=z[i][0];
    con[i].number=z[i][1];
}
}
void MainWindow::contrast2(pukerclass *can1, pukerclass *can2,pukerclass *con){
    for(int i=0;i<7;i++){
        can1[i].number=con[i].number;
        can1[i].type=con[i].type;
    }
    for(int i=0;i<7;i++){
        can2[i].number=con[i+2].number;
        can2[i].type=con[i+2].type;
    }

}
void MainWindow::showit(pukerclass can1,int a,int b){
if(can1.number==2&&can1.type==1){
    QPainter painter(this);
        painter.drawPixmap(a,b,200,250,QPixmap(":/drawer/红心2.jpg"));
}
if(can1.number==3&&can1.type==1){
    QPainter painter(this);
        painter.drawPixmap(a,b,200,250,QPixmap(":/drawer/红心3.jpg"));
}
if(can1.number==4&&can1.type==1){
    QPainter painter(this);
        painter.drawPixmap(a,b,200,250,QPixmap(":/drawer/红心4.jpg"));
}
if(can1.number==5&&can1.type==1){
    QPainter painter(this);
        painter.drawPixmap(a,b,200,250,QPixmap(":/drawer/红心5.jpg"));
}
if(can1.number==6&&can1.type==1){
    QPainter painter(this);
        painter.drawPixmap(a,b,200,250,QPixmap(":/drawer/红心6.jpg"));
}
if(can1.number==7&&can1.type==1){
    QPainter painter(this);
        painter.drawPixmap(a,b,200,250,QPixmap(":/drawer/红心7.jpg"));
}
if(can1.number==8&&can1.type==1){
    QPainter painter(this);
        painter.drawPixmap(a,b,200,250,QPixmap(":/drawer/红心8.jpg"));
}
if(can1.number==9&&can1.type==1){
    QPainter painter(this);
        painter.drawPixmap(a,b,200,250,QPixmap(":/drawer/红心9.jpg"));
}
if(can1.number==10&&can1.type==1){
    QPainter painter(this);
        painter.drawPixmap(a,b,200,250,QPixmap(":/drawer/红心10.jpg"));
}
if(can1.number==11&&can1.type==1){
    QPainter painter(this);
        painter.drawPixmap(a,b,200,250,QPixmap(":/drawer/红心11.jpg"));
}
if(can1.number==12&&can1.type==1){
    QPainter painter(this);
        painter.drawPixmap(a,b,200,250,QPixmap(":/drawer/红心12.jpg"));
}
if(can1.number==13&&can1.type==1){
    QPainter painter(this);
        painter.drawPixmap(a,b,200,250,QPixmap(":/drawer/红心13.jpg"));
}
if(can1.number==14&&can1.type==1){
    QPainter painter(this);
        painter.drawPixmap(a,b,200,250,QPixmap(":/drawer/红心1.jpg"));
}
if(can1.number==2&&can1.type==2){
    QPainter painter(this);
        painter.drawPixmap(a,b,200,250,QPixmap(":/drawer/方块2.jpg"));
}
if(can1.number==3&&can1.type==2){
    QPainter painter(this);
        painter.drawPixmap(a,b,200,250,QPixmap(":/drawer/方块3.jpg"));
}
if(can1.number==4&&can1.type==2){
    QPainter painter(this);
        painter.drawPixmap(a,b,200,250,QPixmap(":/drawer/方块4.jpg"));
}
if(can1.number==5&&can1.type==2){
    QPainter painter(this);
        painter.drawPixmap(a,b,200,250,QPixmap(":/drawer/方块5.jpg"));
}
if(can1.number==6&&can1.type==2){
    QPainter painter(this);
        painter.drawPixmap(a,b,200,250,QPixmap(":/drawer/方块6.jpg"));
}
if(can1.number==7&&can1.type==2){
    QPainter painter(this);
        painter.drawPixmap(a,b,200,250,QPixmap(":/drawer/方块7.jpg"));
}
if(can1.number==8&&can1.type==2){
    QPainter painter(this);
        painter.drawPixmap(a,b,200,250,QPixmap(":/drawer/方块8.jpg"));
}
if(can1.number==9&&can1.type==2){
    QPainter painter(this);
        painter.drawPixmap(a,b,200,250,QPixmap(":/drawer/方块9.jpg"));
}
if(can1.number==10&&can1.type==2){
    QPainter painter(this);
        painter.drawPixmap(a,b,200,250,QPixmap(":/drawer/方块10.jpg"));
}
if(can1.number==11&&can1.type==2){
    QPainter painter(this);
        painter.drawPixmap(a,b,200,250,QPixmap(":/drawer/方块11.jpg"));
}
if(can1.number==12&&can1.type==2){
    QPainter painter(this);
        painter.drawPixmap(a,b,200,250,QPixmap(":/drawer/方块12.jpg"));
}
if(can1.number==13&&can1.type==2){
    QPainter painter(this);
        painter.drawPixmap(a,b,200,250,QPixmap(":/drawer/方块13.jpg"));
}
if(can1.number==14&&can1.type==2){
    QPainter painter(this);
        painter.drawPixmap(a,b,200,250,QPixmap(":/drawer/方块1.jpg"));
}
if(can1.number==2&&can1.type==3){
    QPainter painter(this);
        painter.drawPixmap(a,b,200,250,QPixmap(":/drawer/黑桃2.jpg"));
}
if(can1.number==3&&can1.type==3){
    QPainter painter(this);
        painter.drawPixmap(a,b,200,250,QPixmap(":/drawer/黑桃3.jpg"));
}
if(can1.number==4&&can1.type==3){
    QPainter painter(this);
        painter.drawPixmap(a,b,200,250,QPixmap(":/drawer/黑桃4.jpg"));
}
if(can1.number==5&&can1.type==3){
    QPainter painter(this);
        painter.drawPixmap(a,b,200,250,QPixmap(":/drawer/黑桃5.jpg"));
}
if(can1.number==6&&can1.type==3){
    QPainter painter(this);
        painter.drawPixmap(a,b,200,250,QPixmap(":/drawer/黑桃6.jpg"));
}
if(can1.number==7&&can1.type==3){
    QPainter painter(this);
        painter.drawPixmap(a,b,200,250,QPixmap(":/drawer/黑桃7.jpg"));
}
if(can1.number==8&&can1.type==3){
    QPainter painter(this);
        painter.drawPixmap(a,b,200,250,QPixmap(":/drawer/黑桃8.jpg"));
}
if(can1.number==9&&can1.type==3){
    QPainter painter(this);
        painter.drawPixmap(a,b,200,250,QPixmap(":/drawer/黑桃9.jpg"));
}
if(can1.number==10&&can1.type==3){
    QPainter painter(this);
        painter.drawPixmap(a,b,200,250,QPixmap(":/drawer/黑桃10.jpg"));
}
if(can1.number==11&&can1.type==3){
    QPainter painter(this);
        painter.drawPixmap(a,b,200,250,QPixmap(":/drawer/黑桃11.jpg"));
}
if(can1.number==12&&can1.type==3){
    QPainter painter(this);
        painter.drawPixmap(a,b,200,250,QPixmap(":/drawer/黑桃12.jpg"));
}
if(can1.number==13&&can1.type==3){
    QPainter painter(this);
        painter.drawPixmap(a,b,200,250,QPixmap(":/drawer/黑桃13.jpg"));
}
if(can1.number==14&&can1.type==3){
    QPainter painter(this);
        painter.drawPixmap(a,b,200,250,QPixmap(":/drawer/黑桃1.jpg"));
}
if(can1.number==2&&can1.type==4){
    QPainter painter(this);
        painter.drawPixmap(a,b,200,250,QPixmap(":/drawer/梅花2.jpg"));
}
if(can1.number==3&&can1.type==4){
    QPainter painter(this);
        painter.drawPixmap(a,b,200,250,QPixmap(":/drawer/梅花3.jpg"));
}
if(can1.number==4&&can1.type==4){
    QPainter painter(this);
        painter.drawPixmap(a,b,200,250,QPixmap(":/drawer/梅花4.jpg"));
}
if(can1.number==5&&can1.type==4){
    QPainter painter(this);
        painter.drawPixmap(a,b,200,250,QPixmap(":/drawer/梅花5.jpg"));
}
if(can1.number==6&&can1.type==4){
    QPainter painter(this);
        painter.drawPixmap(a,b,200,250,QPixmap(":/drawer/梅花6.jpg"));
}
if(can1.number==7&&can1.type==4){
    QPainter painter(this);
        painter.drawPixmap(a,b,200,250,QPixmap(":/drawer/梅花7.jpg"));
}
if(can1.number==8&&can1.type==4){
    QPainter painter(this);
        painter.drawPixmap(a,b,200,250,QPixmap(":/drawer/梅花8.jpg"));
}
if(can1.number==9&&can1.type==4){
    QPainter painter(this);
        painter.drawPixmap(a,b,200,250,QPixmap(":/drawer/梅花9.jpg"));
}
if(can1.number==10&&can1.type==4){
    QPainter painter(this);
        painter.drawPixmap(a,b,200,250,QPixmap(":/drawer/梅花10.jpg"));
}
if(can1.number==11&&can1.type==4){
    QPainter painter(this);
        painter.drawPixmap(a,b,200,250,QPixmap(":/drawer/梅花11.jpg"));
}
if(can1.number==12&&can1.type==4){
    QPainter painter(this);
        painter.drawPixmap(a,b,200,250,QPixmap(":/drawer/梅花12.jpg"));
}
if(can1.number==13&&can1.type==4){
    QPainter painter(this);
        painter.drawPixmap(a,b,200,250,QPixmap(":/drawer/梅花13.jpg"));
        }
if(can1.number==14&&can1.type==4){
    QPainter painter(this);
        painter.drawPixmap(a,b,200,250,QPixmap(":/drawer/梅花1.jpg"));
        }
}

